<template>
  <div>
    <!-- 首页商品分类全局组件 -->
    <type-nav></type-nav>
    <ListContainer></ListContainer>
    <Recommend></Recommend>
    <Rank></Rank>
    <Like></Like>
    <!-- 通过v-for遍历出Floor组件 -->
    <!-- 组件通信手段:props -->
    <Floor v-for="(floor,index) in floorList" :key="floor.id" :floor="floor"></Floor>
    <Brand></Brand>
  </div>
</template>

<script>
//辅助函数获取Floor数据
//引入子组件
import ListContainer from "./listContauner";
import Recommend from "./recommend";
import Rank from "./rank";
import Like from "./like";
import Floor from "./floor";
import Brand from './brand'
import { mapState } from 'vuex';
export default {
  name: "Home",
  //注册:使用局部组件之前务必注册，不注册不能使用
  components: {
    ListContainer,
    Recommend,
    Rank,
    Like,
    Floor,
    Brand
  },
  //父组件挂载完毕
  mounted() {
    this.$store.dispatch('floorList');
     //登录成功以后获取用户信息
     this.$store.dispatch('getUserInfo');
  },
  computed:{
    ...mapState({
        floorList:state=>state.home.floorList
    })
  }

};
</script>

<style scoped>
</style>
